package cn.bigcontainer.common.exception;

public class BCResultCode {

	private String msg = "未知错误!";

	private Integer code = 0;

	private Object content = "";

	public BCResultCode() {
	}

	public BCResultCode(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public Boolean getSuccess() {
		return code == 1;
	}

	public void setMsgArgs(Object... args) {
		if (args == null || args.length == 0) {
			return;
		}
		msg = String.format(msg, args);
	}

	public String getMsg() {
		return msg;
	}

	public String getMessage() {
		return msg;
	}

	public BCResultCode setMsg(String msg) {
		this.msg = msg;
		return this;
	}

	public Object getContent() {
		return content;
	}

	public BCResultCode setContent(Object content) {
		if (content != null) {
			this.content = content;
		}
		return this;
	}

	/**
	 * @return
	 */
	public BCResultCode cloneCode() {
		BCResultCode code = new BCResultCode(this.code, this.msg);
		code.setContent(this.content);
		return code;
	}

	/**
	 * @return
	 */
	public static BCResultCode getSuccessCode() {
		return new BCResultCode(1, "操作成功！");
	}

	/**
	 * @return
	 */
	public static BCResultCode getUnknownCode() {
		return new BCResultCode();
	}
}
